﻿<FluentTreeView @bind-CurrentSelected=currentSelected OnExpandedChange="HandleOnExpandedChanged">
    <FluentTreeItem Text="Root item 1">
        <FluentTreeItem Text="Flowers">
            <FluentTreeItem Disabled="true" Text="Daisy" />
            <FluentTreeItem Text="Sunflower" />
            <FluentTreeItem Text="Rose" />
        </FluentTreeItem>
        <FluentTreeItem Text="Nested item 2" />
        <FluentTreeItem Text="Nested item 3" />
    </FluentTreeItem>
    <FluentTreeItem Text="Root item 2">
        <FluentDivider></FluentDivider>
        <FluentTreeItem Text="Flowers">
            <FluentTreeItem Disabled="true" Text="Daisy" />
            <FluentTreeItem Text="Sunflower" />
            <FluentTreeItem Text="Rose" />
        </FluentTreeItem>
        <FluentTreeItem Text="Nested item 2" />
        <FluentTreeItem Text="Nested item 3" />
    </FluentTreeItem>
    <FluentTreeItem Text="Root item 3 - Leaf Erikson" />
</FluentTreeView>

<p>Current selected tree item is @currentSelected?.Text</p>
<p>Most recently expanded/collapsed tree item is @currentAffected?.Text</p>

@code {
    FluentTreeItem? currentSelected;
    FluentTreeItem? currentAffected;

    private void HandleOnExpandedChanged(FluentTreeItem item)
    {
        currentAffected = item;
    }
}